package WaiBao;

import java.util.Arrays;

public class YangHuaChen {
    public static void main(String[] args) {
        String[] name = {"郭金(班长)", "郭晶晶(团支书)", "小李(学习委员)", "李甜甜(文艺委员)", "张晓", "李耀宇", "张强", "王皓", "李凯凯", "王静卡", "李凯", "李思远",
                "李嗣源", "李浩天", "王昊", "张翔宇", "王保国", "李援朝", "张海", "季昌明", "高育良", "程度", "膏小青", "赵瑞龙", "高小琴", "张怀个", "赵德贵", "赵怀安",
                "李畅畅", "杨烨晨(学生)"};//考生本人: 杨烨晨(学生)
        int[] age = {21,18, 19,20, 19, 20,19, 21, 21, 21, 19, 22, 23, 21, 21, 19, 18, 20, 18, 18, 19, 19, 20, 20, 20, 19,20,21,22, 18};//最后一位：考生年龄:18

        double[] jaingnan1 = {74, 86, 84, 84, 89, 69, 74, 80, 84, 80, 81, 84, 85, 88, 85, 68, 70, 70, 76, 84, 92, 91, 95, 65, 75, 74, 94, 84, 84, 96};
        double[] jaingnan2 = {84, 84, 97, 76, 74, 77, 79, 79, 81, 74, 70, 77, 80, 90, 80, 64, 76, 79, 64, 98, 72, 71, 95, 86, 75, 84, 84, 75, 81, 95};
        double[] jaingnan3 = {94, 76, 84, 85, 74, 66, 68, 74, 80, 80, 93, 87, 85, 65, 85, 68, 69, 96, 96, 93, 92, 81, 65, 95, 76, 87, 73, 75, 89, 97};


        double xiang1;//代表每个学生的总分
        double xiang2;//代表每个学生的平均分
//        for (int i = 0; i < 30; i++) {
//            xiang1 =jaingnan1[i] + jaingnan2[i] +jaingnan3[i];
//            xiang2 = (xiang1 * 1.0) / 3;
//            System.out.println(name[i] + "的总分为:" + xiang1);
//            System.out.println(name[i] + "的平均分为:" + xiang2);
//        }



        double know1 = 0,know2 = 0;
        double[] Arr = new double[30];
//        for (int i = 0; i < 30; i++) {
//            know1 =jaingnan1[i] +jaingnan2[i] + jaingnan3[i];
//            know2= (know1 * 1.0) / 3;
//            Arr[i] = know2;
//        }
//
//        for (int i = 0; i < Arr.length - 1; i++) {
//            for (int j = 0; j < Arr.length - i - 1; j++) {
//                if (Arr[j] < Arr[j + 1]) {
//                    double tep = Arr[j];
//                    Arr[j] = Arr[j + 1];
//                    Arr[j + 1] = tep;
//                }
//            }
//        }
//        System.out.println("前十名同学的成绩为:");
//        for (int i = 0; i < 10; i++) {
//            System.out.println(Arr[i]);
//        }

        double haishi1 = 0, haishi2 = 0, xiulian3 = 0;//计算每门课的平均分
        double demo1 = 0, demo2 = 0, demo3 = 0;//计算每门课标准差
        double nali1 = 0,nali2 = 0, nali3 = 0;//计算每门课中位数
        double he = 0;
        for (int i = 0; i <jaingnan1.length; i++) {
            he += jaingnan1[i];
        }
        haishi1 = (he * 1.0) / 30;
        System.out.println("生物化学的班级平均分为:" + haishi1);
        double Sum = 0;
        for (int i = 0; i < jaingnan2.length; i++) {
            Sum +=jaingnan3[i];
        }
        haishi2 = (Sum * 1.0) / 30;
        System.out.println("物理化学的班级平均分为:" +haishi2);
        double sum = 0;
        for (int i = 0; i < jaingnan3.length; i++) {
            sum +=jaingnan3[i];
        }
        xiulian3 = (sum * 1.0) / 30;
        System.out.println("电子与电工技术的班级平均分为:" + xiulian3);

//
        double c1 = 0, c2 = 0, c3 = 0;
        for (int i = 0; i <jaingnan1.length; i++) {
            c1 += (jaingnan1[i] -haishi1) * (jaingnan1[i] -haishi1);
        }
        demo1 = Math.sqrt(c1*1.0/30);
        System.out.println("生物化学的班级标准差为:" + demo1);
        for (int i = 0; i < jaingnan2.length; i++) {
            c2 += (jaingnan2[i] - haishi2) * (jaingnan2[i] - haishi2);
        }
        demo2 = Math.sqrt(c2*1.0/30);
        System.out.println("物理化学的班级标准差为:" + demo2);

        for (int i = 0; i <jaingnan3.length; i++) {
            c3 += (jaingnan3[i] - xiulian3) * (jaingnan3[i] - xiulian3);
        }
        demo3 = Math.sqrt(c3*1.0/30);
        System.out.println("电子与电工技术的班级标准差为:" + demo3);
//////////
////////
////////
        Arrays.sort(jaingnan1);
        Arrays.sort(jaingnan2);
        Arrays.sort(jaingnan3);
        nali1 = (jaingnan1[14] + jaingnan2[15]) * 1.0 / 2;
        nali2 = (jaingnan2[14] + jaingnan2[15]) * 1.0 / 2;
        nali3 = (jaingnan3[14] + jaingnan3[15]) * 1.0 / 2;
        System.out.println("生物化学的中位数为:" + nali1);
        System.out.println("物理化学的中位数为:" + nali2);
        System.out.println("电子与电工技术的中位数为:" + nali3);

    }
}
